#include<bits/stdc++.h>

namespace IO{
    template<typename T>
    void read(T &x){
        char ch=getchar();int fl=1;x=0;
        while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getchar();}
        while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getchar();}
        x*=fl;
    }
    template<typename T,typename ...Args>
    void read(T &x,Args& ...args){
        read(x);read(args...);
    }
    template <typename _Tp>
    void write(_Tp x) {
        if(x<0) x=(~x+1),putchar('-');
        if(x>9) write(x/10);
        putchar(x%10+'0');
    }
}
using namespace std;
using namespace IO;
const int N=2e5+5,mod=998244353;
int fac[N],inv[N];
int ksm(int x,int y) {
    int ans=1;
    while(y) {
        if(y&1) ans=(1ll*ans*x)%mod;
        x=(1ll*x*x)%mod; y>>=1;
    }
    return ans;
}	
__int128 mu;
inline long long reduce(__int128 x) {
	__int128 r=x-(mu*x>>64)*mod;
	return r;
}
inline void init(int ops) {
    fac[0]=1;
    mu=(__int128)(((__int128)1)<<64)/mod;
    if(!ops) return ;
    for(int i=1;i<N;i++) fac[i]=(1ll*fac[i-1]*i)%mod;
    inv[N-1]=ksm(fac[N-1],mod-2);
    for(int i=N-2;i>=0;i--) inv[i]=(1ll*inv[i+1]*(i+1))%mod;
}
inline int Inc(int x,int y) {return x+y<mod?x+y:x+y-mod;}
inline int Dec(int x,int y) {return x>=y?x-y:x-y+mod;}
inline int Mul(int x,int y) {return reduce(1ll*x*y);}
int n,a[N],cnt;
map<vector<int>,int> ma;
void dfs(vector<int> vec) {
    if(ma.count(vec)) return ;
    for(int i=0;i<n;i++) printf("%d ",vec[i]);
    printf("\n");
    ma[vec]++;cnt++;
    for(int i=0;i<n-1;i++) {
        vector<int> to=vec;
        to[i]=max(to[i],to[i+1]);
        to[i+1]=max(to[i],to[i+1]);
        dfs(to);
    }
}
signed main() {
#ifndef KAxdd
#ifndef ONLINE_JUDGE
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
#endif
#endif
    read(n);
    vector<int> vec;
    for(int i=1;i<=n;i++) {
        read(a[i]);
        vec.push_back(a[i]);
    }
    dfs(vec);
    printf("%d\n",cnt);
    return 0;
}   
/*
4
1 4 2 3
*/